//
//  TabBarButton.swift
//  SwiftProject
//
//  Created by wwj on 16/2/23.
//  Copyright © 2016年 wwj. All rights reserved.
//

import UIKit


class TabBarButton: UIButton {
    let kScal = 0.6
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.titleLabel?.textAlignment = NSTextAlignment.center;
        self.imageView?.contentMode = UIViewContentMode.center
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func titleRect(forContentRect contentRect: CGRect) -> CGRect {
        let y = contentRect.size.height * CGFloat(kScal)
        let h = contentRect.size.height * CGFloat((1 - kScal))
        let w = contentRect.size.width
        return CGRect(x: 0, y: y, width: w, height: h)
    }
    
    override func imageRect(forContentRect contentRect: CGRect) -> CGRect {
        let w = contentRect.size.width
        let h = contentRect.size.height * CGFloat(kScal)
        return  CGRect(x: 0, y: 2, width: w, height: h)
    }

}
